package com.daidai.dao;

import com.daidai.domain.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookDao {

    @Select("select * from ssm_db.tbl_book")
    public List<Book> getAllBooks();

    @Select("select * from ssm_db.tbl_book where id = #{id}")
    public Book getBookById(Integer id);

    @Insert("insert into ssm_db.tbl_book(type, name, description) values (#{type}, #{name}, #{description})")
    public int saveBook(Book book);

    @Delete("delete from ssm_db.tbl_book where id = #{id}")
    public int deleteBook(Integer id);

    @Update("update ssm_db.tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")
    public int updateBook(Book book);
}
